package com.excel.service;

import com.excel.mapper.ImportInfoFailReasonRepository;
import com.excel.mapper.ImportInfoRepository;
import com.excel.entity.ImportInfo;
import com.excel.entity.ImportInfoFailReason;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author User
 */
@Service
public class ImportDomainService {


    @Resource
    private ImportInfoRepository importInfoRepository;

    @Resource
    private ImportInfoFailReasonRepository importInfoFailReasonRepository;

    public List<ImportInfo> listUnfinished() {
        return importInfoRepository.listUnfinished();
    }

    public boolean saveImportInfo(ImportInfo importInfo) {
        return importInfoRepository.save(importInfo);
    }

    public boolean saveImportInfoFail(ImportInfoFailReason importInfoFailReason) {
        return importInfoFailReasonRepository.save(importInfoFailReason);
    }

    public List<ImportInfoFailReason> listImportInfoFailReason(Integer importInfoId) {
        return importInfoFailReasonRepository.listByImportInfoId(importInfoId);
    }

    public boolean updateImportInfo(ImportInfo importInfo) {
        return importInfoRepository.update(importInfo);
    }

    public ImportInfo getImportInfoById(Integer id) {
        return importInfoRepository.findById(id);
    }


}
